<template>
	<view class="changeName-page">
		<navigation :navigationMsg="navigationMsg"></navigation>
		<view class="main">
			<view class="name">
				<view class="title">
					昵称
				</view>
				<u--input fontSize="34rpx" v-model="nameInput" border="none"></u--input>
			</view>
			<view class="tip">

			</view>
			<view class="submit" @click="submit">
				修改
			</view>
		</view>
	</view>
</template>

<script>
	import {
		http,
		uploadFile
	} from '@/api/index.js'
	import navigation from '../../../../components/navigation.vue';
	export default {
		data() {
			return {
				navigationMsg: {
					title: "修改昵称"
				},
				nameInput: ""
			}
		},
		components: {
			navigation
		},
		onShow() {
			this.getUserInfo()
		},
		methods: {
			//获取会员资料
			getUserInfo() {
				http.post('/api/account/getUserInfo').then(res => {
					this.nameInput = res.nickname
				}).catch(err => {
					// console.log(err.data.data);

				})
			},
			//修改
			submit() {
				http.post('/api/account/changeNickName', {
					nickname: this.nameInput
				}).then(res => {
					uni.navigateBack()
				}).catch(err => {
					// console.log(err);
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.changeName-page {
		width: 100%;
		height: 100vh;
		background-color: #f7f7f7;

		.main {
			width: 100%;
			height: calc(100% - 100rpx);
			position: relative;
			overflow: hidden;

			.name {
				width: 90%;
				height: 100rpx;
				background-color: white;
				border-radius: 10rpx;
				margin: auto;
				margin-top: 30rpx;
				display: flex;
				align-items: center;
				font-size: 34rpx;
				justify-content: space-between;

				.title {
					width: 170rpx;
					text-align: center;
					margin-right: 20rpx;
				}
			}

			.submit {
				width: 90%;
				height: 80rpx;
				background-color: black;
				color: white;
				text-align: center;
				line-height: 80rpx;
				border-radius: 50rpx;
				position: absolute;
				bottom: 30rpx;
				left: 5%;
			}
		}
	}
</style>